﻿using BackboneTest.Domain;
using BackboneTest.Models;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BackboneTest.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Users() 
        {
            var users = UserRepository.Instace.GetUsers();
            return Json(users, JsonRequestBehavior.AllowGet);
        }

        [HttpGet]
        public ActionResult UserService(int id)
        {
            var user = UserRepository.Instace.GetUser(id);
            return Json(user, JsonRequestBehavior.AllowGet);
        }

        [HttpPost]
        public ActionResult UserService(User user)
        {
            UserRepository.Instace.SaveUser(user);
            return Json(user);
        }
    }


}